// src/api/modules/feedback.js
import request from "../request";

export default {
  createFeedback(userId, data) {
    // 确保userId是数值类型
    if (typeof userId !== "number") {
      throw new Error("userId必须为数值类型");
    }

    return request({
      url: `api/feedback/createFeedback/${userId}`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: JSON.stringify(data),
    });
  },

  /**
   * 回复反馈
   * @param {number} id - 反馈ID
   * @param {Object} data - { reply: string, operatorId: number }
   */
  replyFeedback(id, data) {
    return request.post(`/api/feedback/replyFeedback/${id}`, null, {
      params: {
        reply: data.reply,
        operatorId: data.operatorId,
      },
    });
  },

  deleteFeedback(id, userId) {
    return request.delete(`/api/feedback/deleteFeedback/${id}`, {
      params: { userId },
    });
  },

  getFeedbackList(params) {
    return request({
      url: "/api/feedback/listFeedbacks",
      method: "get",
      params: {
        status: params.status,
        userId: params.userId,
        page: params.page,
        size: params.size,
      },
    });
  },
};
